﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace HPPClientLibrary.XmlableObject
{
    using System.Xml.Linq;

    public class ShareFileList :List<File>,IXmlable 
    {
        public virtual  XDocument ToXml()
        {
            XDocument xdoc = new XDocument();
            xdoc.Declaration = new XDeclaration("1.0", "utf-8", "yes");
            XElement shareFiles = new XElement("ShareFiles");
            foreach (File file in this)
            {
                shareFiles.Add(new XElement("File",new XAttribute("FileName",file.FileName),new XAttribute("Hash",file.Hash),new XAttribute("Size",file.Size)));
            }
            xdoc.Add(shareFiles);
            return xdoc;
        }
        public void AddFile(File file)
        {
            Add(file);
        }
        public bool RemoveFile(File file)
        {
            if (Remove(file))
            {
                return true;
            }
            return false;
        }
    }
}

